import React from 'react';
import PropTypes from 'prop-types'
class Empty extends React.Component {
  constructor(props) {
    super(props)
    this.reload = this.reload.bind(this)
    this.goback = this.goback.bind(this)
  }
  reload = () => {
    window.location.reload(true)
  }
  goback = () => {
    window.history.back()
  }
  render() {
    let { text, type } = this.props
    type = type === 'reload'
    return (
      <div style={style.styles}>
        <div
          style={{ minHeight: '100vh', paddingTop: '20rem', boxSizing: 'border-box', textAlign: 'center' }}
          onClick={type ? this.reload : this.goback}
        >加载失败了<br />
          <span>{type ? text + '点击空白处重新加载' : text + '点击空白处返回上级'}</span></div>
      </div>
    )
  }
}
const style = {
  styles: { display: 'flex', flexDirection: 'column', justifyContent: 'center' },
}
Empty.propTypes={
  type:PropTypes.string.isRequired,
  text:PropTypes.string.isRequired
}
export default Empty